package com.hmdp.utils;

import com.hmdp.service.IBlogService;

import java.util.List;
import java.util.concurrent.Callable;

public class ThredQuery implements Callable<List> {

    public static SpringContextUtil springContextUtil = new SpringContextUtil();

    private int start;

    private int end;

    //每个线程查询出来的数据集合
    private List datas;

    public  ThredQuery(int start,int end) {
        this.start=start;
        this.end=end;
        //每个线程查询出来的数据集合
//        QueryService queryService= springContextUtil.getBean("queryService");
        //上面获取bean实例的方法可能会失效
        IBlogService blogService = springContextUtil.getBean(IBlogService.class);
        List count = blogService.getQueryData(start,end);
        datas = count;
    }

    //返回数据给Future
    @Override
    public List call() throws Exception {
        return datas;
    }
}

